#include <iostream>
using namespace std;

class Base
{
public:
    Base() { cout << "in Base's constructor.." << endl; }
    Base(const Base&) { cout << "in Base's copy constructor.." << endl; }
    Base& operator=(const Base&) { cout << "in Base's assign operator.." << endl; return *this; }
    ~Base() { cout << "in Base's destructor.." << endl; }
};

class Derived : public Base
{
    int i;
public:
    /* Default constructor of Base is called automatically. */
    Derived(int i) { cout << "in Derived's constructor.." << endl; this->i = i; }
    /* Copy constructor must be called explicitly, otherwise default constructor is called. */
    Derived(const Derived& d) : Base(d), i(d.i) {
        cout << "in Derived's copy constructor.." << endl;
    }
    Derived& operator=(const Derived& d) {
        Base::operator=(d);
        cout << "in Derived's assign operator.." << endl;
        i = d.i;
        return *this;
    }
    ~Derived() { cout << "in Derived's destructor.." << endl; }
};

#if 0
int main() {
    Derived d(10);
    Derived d2 = d;
    d = d2;
    return 0;
}
#endif
